package demo3;

import demo4.IRun;
import demo4.ISwim;

import java.util.Objects;

/**
 * @Author: Lenovo
 * @Date: 2024/5/22 22:44
 * @description:
 */
public class Dog /*extends Animal implements IRun,ISwim*/{

    public String name;
    public int age;

    public Dog(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public String toString() {
        return "Dog{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    @Override
    public boolean equals(Object obj) {
        return super.equals(obj);
    }
    /*@Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Dog dog = (Dog) o;
        return age == dog.age && Objects.equals(name, dog.name);
    }*/

    @Override
    public int hashCode() {
        return Objects.hash(name, age);
    }
/*public Dog(String name, int age) {
        super(name, age);
    }

    @Override
    public void eat() {
        System.out.println(this.name+" 正在吃狗粮...");
    }

    @Override
    public void Run() {
        System.out.println(this.name+ " 正在跑步...");
    }

    @Override
    public void Swim() {
        System.out.println(this.name+" 正在游泳...");
    }


    @Override
    public boolean equals(Object obj) {
        if(obj == null) {
            return false;
        }
        if(this == obj) {
            return true;
        }
        //是不同同一个类型
        if(!(obj instanceof Dog)) {
            return false;
        }

        Dog tmp = (Dog)obj;
        return tmp.name.equals(this.name)
                && tmp.age == this.age;
    }

    @Override
    public String toString() {
        return "Dog{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }*/


}
